#ifndef __PLANE_H__
#define __PLANE_H__

#pragma once

#include "Vector3.h"

namespace Nezha
{
	class AABB;

	/** N*P = -D */
	class NEZHA_ENGINE_ENTRY Plane
	{
	public:
		enum Side
		{
			SIDE_NONE,
			SIDE_POSITIVE,
			SIDE_NEGATIVE,
			SIDE_BOTH
		};

		Plane()
			:mNormal(Vector3::ZERO)
			,mConstant(0)
		{
		}

		Plane(const Vector3& n, float c)
			:mNormal(n)
			,mConstant(c)
		{
		}

		Plane(const Vector3& p0, const Vector3& p1, const Vector3& p2);

		float distane2(const Vector3& p) const;

		void reset(const Vector3& p0, const Vector3& p1, const Vector3& p2);

		Side whichSide(const Vector3& p) const;

		Side whichSide(const AABB& aabb) const;

		Side whichSide(const Vector3& center, const Vector3& halfSize) const;

		Vector3 mNormal;
		float mConstant;
	};

}//end namespace Nezha

#endif //end __PLANE_H__